<script>
import { unique } from '@/utils/string'

export default {
  name: 'BiChartQuotaItemProxy',
  inject: ['UiChartQuota'],
  props: {
    label: {
      type: String
    },
    value: {
      type: String
    },
    icon: {
      type: String
    },
    unit: {
      type: String
    }
  },
  computed: {
    item () {
      return {
        id: this.id,
        props: this.$props,
        component: {
          functional: true,
          render: (h) => {
            return this.$slots.default
          }
        }
      }
    }
  },
  render () {
    return null
  },
  created () {
    this.id = unique()
    this.UiChartQuota.addItem(this.item)
  },
  beforeDestroy () {
    this.UiChartQuota.removeItem(this.id)
  }
}
</script>
